package com.hopu.mybatis02.exception;
import com.hopu.mybatis02.pojo.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public R handleException(Exception e) {
        e.printStackTrace();
        return R.err(e.getMessage());
    }

    @ExceptionHandler(BusinessException.class)
    public R handleServiceException(BusinessException e) {
        e.printStackTrace();
        return R.err(e.getMessage());
    }
}
